#!/bin/bash

npm set "@${NPM_PRIVATE_SCOPE}:registry" "https:${NPM_PRIVATE_REGISTRY}"
npm set "${NPM_PRIVATE_REGISTRY}:username" "${NPM_PRIVATE_USERNAME}"
npm set "${NPM_PRIVATE_REGISTRY}:_password" "${NPM_PRIVATE_PASSWORD}"
npm set "${NPM_PRIVATE_REGISTRY}:email" "${NPM_PRIVATE_EMAIL}"

yarn "$@"
EXIT_CODE=$?

npm config delete "@${NPM_PRIVATE_SCOPE}:registry"
npm config delete "${NPM_PRIVATE_REGISTRY}:username"
npm config delete "${NPM_PRIVATE_REGISTRY}:_password"
npm config delete "${NPM_PRIVATE_REGISTRY}:email"

exit $EXIT_CODE
